home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1993 / MacHack 1993.toast / MacHack™ 1987-1992 / MacHack™ '90 / Source Code ƒ / Misc. Pascal ƒ / Jay's Cookie / CookieEdit.r < prev    next >
Encoding:
Text File  |  1989-08-08  |  9.2 KB  |  406 lines  |  [TEXT/MPS ]

  1. /*------------------------------------------------------------------------------
  2. #
  3. #    Apple Macintosh Developer Technical Support
  4. #
  5. #    MultiFinder-Aware TextEdit Sample Application
  6. #
  7. #    TESample
  8. #
  9. #    TESample.r    -    Rez Source
  10. #
  11. #    Copyright © 1988 Apple Computer, Inc.
  12. #    All rights reserved.
  13. #
  14. #    Versions:    1.0                    08/88
  15. #                1.01                11/88
  16. #
  17. #    Components:    TESample.p            November 1, 1988
  18. #                TESample.c            November 1, 1988
  19. #                TESampleGlue.a        November 1, 1988
  20. #                TESample.r            November 1, 1988
  21. #                TESample.h            November 1, 1988
  22. #                [P]TESample.make    November 1, 1988
  23. #                [C]TESample.make    November 1, 1988
  24. #
  25. #    TESample is an example application that demonstrates how 
  26. #    to initialize the commonly used toolbox managers, operate 
  27. #    successfully under MultiFinder, handle desk accessories and 
  28. #    create, grow, and zoom windows. The fundamental TextEdit 
  29. #    toolbox calls and TextEdit autoscroll are demonstrated. It 
  30. #    also shows how to create and maintain scrollbar controls.
  31. #
  32. #    It does not by any means demonstrate all the techniques you 
  33. #    need for a large application. In particular, Sample does not 
  34. #    cover exception handling, multiple windows/documents, 
  35. #    sophisticated memory management, printing, or undo. All of 
  36. #    these are vital parts of a normal full-sized application.
  37. #
  38. #    This application is an example of the form of a Macintosh 
  39. #    application; it is NOT a template. It is NOT intended to be 
  40. #    used as a foundation for the next world-class, best-selling, 
  41. #    600K application. A stick figure drawing of the human body may 
  42. #    be a good example of the form for a painting, but that does not 
  43. #    mean it should be used as the basis for the next Mona Lisa.
  44. #
  45. #    We recommend that you review this program or Sample before 
  46. #    beginning a new application. Sample is a simple app. which doesn’t 
  47. #    use TextEdit or the Control Manager.
  48. #
  49. ------------------------------------------------------------------------------*/
  50.  
  51. #include "SysTypes.r"
  52. #include "Types.r"
  53.  
  54. #define    mApple                    128        /* Apple menu */
  55. #define    iAbout                    1
  56.  
  57. #define    mFile                    129        /* File menu */
  58. #define    iNew                    1
  59. #define    iClose                    4
  60. #define    iQuit                    12
  61.  
  62. #define    mEdit                    130        /* Edit menu */
  63. #define    iUndo                    1
  64. #define    iCut                    3
  65. #define    iCopy                    4
  66. #define    iPaste                    5
  67. #define    iClear                    6
  68.  
  69. #define    mFind                    150
  70. #define    iFind                    1;
  71. #define    iFindSame                2;
  72. #define    iFindSel                3;
  73. #define    iDisplaySel                4;
  74. #define    iReplace                6;
  75. #define    iReplSame                7;
  76. #define    iGotoTop                9;
  77. #define    iGotoBottom                10;
  78. #define    iGotoLine                11;
  79.  
  80. #define    mFortunes                151;
  81. #define    iNewFortune                1;
  82. #define    iDelFortune                2;
  83.  
  84.  
  85. type 'vers' {
  86.         hex byte;                                                /* Major revision in BCD*/
  87.         hex byte;                                                /* Minor vevision in BCD*/
  88.         hex byte    development = 0x20,                            /* Release stage        */
  89.                     alpha = 0x40,
  90.                     beta = 0x60,
  91.                     final = 0x80, /* or */ release = 0x80;
  92.         hex byte;                                                /* Non-final release #    */
  93.         integer        Country;                                    /* Country code            */
  94.         pstring;                                                /* Short version number    */
  95.         pstring;                                                /* Long version number    */
  96. };
  97.  
  98. resource 'vers' (1) {
  99.     0x01, 0x00, release, 0x00,
  100.     verUS,
  101.     "1.10",
  102.     "1.10, Copyright © 1988 Apple Computer, Inc."
  103. };
  104.  
  105. /* we use an MBAR resource to conveniently load all the menus */
  106.  
  107. resource 'MBAR' (rMenuBar, preload) {
  108.     { mApple, mFile, mEdit, mFind };        /* three menus */
  109. };
  110.  
  111.  
  112. resource 'MENU' (mApple, preload) {
  113.     mApple, textMenuProc,
  114.     0b1111111111111111111111111111101,    /* disable dashed line, enable About and DAs */
  115.     enabled, apple,
  116.     {
  117.         "About TESample…",
  118.             noicon, nokey, nomark, plain;
  119.         "-",
  120.             noicon, nokey, nomark, plain
  121.     }
  122. };
  123.  
  124. resource 'MENU' (mFile, preload) {
  125.     mFile, textMenuProc,
  126.     0b0000000000000000000100000000000,    /* enable Quit only, program enables others */
  127.     enabled, "File",
  128.     {
  129.         "New",
  130.             noicon, "N", nomark, plain;
  131.         "Open",
  132.             noicon, "O", nomark, plain;
  133.         "-",
  134.             noicon, nokey, nomark, plain;
  135.         "Close",
  136.             noicon, "W", nomark, plain;
  137.         "Save",
  138.             noicon, "S", nomark, plain;
  139.         "Save As…",
  140.             noicon, nokey, nomark, plain;
  141.         "Revert",
  142.             noicon, nokey, nomark, plain;
  143.         "-",
  144.             noicon, nokey, nomark, plain;
  145.         "Page Setup…",
  146.             noicon, nokey, nomark, plain;
  147.         "Print…",
  148.             noicon, nokey, nomark, plain;
  149.         "-",
  150.             noicon, nokey, nomark, plain;
  151.         "Quit",
  152.             noicon, "Q", nomark, plain
  153.     }
  154. };
  155.  
  156. resource 'MENU' (mEdit, preload) {
  157.     mEdit, textMenuProc,
  158.     0b0000000000000000000000000000000,    /* disable everything, program does the enabling */
  159.     enabled, "Edit",
  160.      {
  161.         "Undo",
  162.             noicon, "Z", nomark, plain;
  163.         "-",
  164.             noicon, nokey, nomark, plain;
  165.         "Cut",
  166.             noicon, "X", nomark, plain;
  167.         "Copy",
  168.             noicon, "C", nomark, plain;
  169.         "Paste",
  170.             noicon, "V", nomark, plain;
  171.         "Clear",
  172.             noicon, nokey, nomark, plain
  173.     }
  174. };
  175.  
  176.  
  177.     mFortunes    = 151;
  178.     iNewFortune    = 1;
  179.     iDelFortune    = 2;
  180.  
  181.  
  182. resource 'MENU' (mFind, preload) {
  183.     mFind, textMenuProc,
  184.     0b0000000000000000000000000000000,    /* enable Quit only, program enables others */
  185.     enabled, "File",
  186.     {
  187.         "Find",
  188.             noicon, "F", nomark, plain;
  189.         "Find Same",
  190.             noicon, "G", nomark, plain;
  191.         "-",
  192.             noicon, nokey, nomark, plain;
  193.         "Find Selection",
  194.             noicon, "H", nomark, plain;
  195.         "Display Selection",
  196.             noicon, nokey, nomark, plain;
  197.         "-",
  198.             noicon, nokey, nomark, plain;
  199.         "Replace",
  200.             noicon, "R", nomark, plain;
  201.         "Replace Same",
  202.             noicon, "T", nomark, plain;
  203.         "-",
  204.             noicon, nokey, nomark, plain;
  205.         "Top of Current",
  206.             noicon, "6", nomark, plain;
  207.         "Bottom of Current",
  208.             noicon, "5", nomark, plain;
  209.         "Goto Cookie…",
  210.             noicon, "C", nomark, plain
  211.     }
  212. };
  213.  
  214. /* this ALRT and DITL are used as an About screen */
  215.  
  216. resource 'ALRT' (rAboutAlert, purgeable) {
  217.     {40, 20, 160, 296}, rAboutAlert, {
  218.         OK, visible, silent;
  219.         OK, visible, silent;
  220.         OK, visible, silent;
  221.         OK, visible, silent
  222.     };
  223. };
  224.  
  225. resource 'DITL' (rAboutAlert, purgeable) {
  226.     { /* array DITLarray: 5 elements */
  227.         /* [1] */
  228.         {88, 184, 108, 264},
  229.         Button {
  230.             enabled,
  231.             "OK"
  232.         },
  233.         /* [2] */
  234.         {8, 8, 24, 274},
  235.         StaticText {
  236.             disabled,
  237.             "MultiFinder-Aware TextEdit Application"
  238.         },
  239.         /* [3] */
  240.         {32, 8, 48, 237},
  241.         StaticText {
  242.             disabled,
  243.             "Copyright © 1988 Apple Computer"
  244.         },
  245.         /* [4] */
  246.         {56, 8, 72, 136},
  247.         StaticText {
  248.             disabled,
  249.             "Brought to you by:"
  250.         },
  251.         /* [5] */
  252.         {80, 24, 112, 167},
  253.         StaticText {
  254.             disabled,
  255.             "Macintosh Developer  Technical Support"
  256.         }
  257.     }
  258. };
  259.  
  260.  
  261. /* this ALRT and DITL are used as an error screen */
  262.  
  263. resource 'ALRT' (rUserAlert, purgeable) {
  264.     {40, 20, 150, 260},
  265.     rUserAlert,
  266.     { /* array: 4 elements */
  267.         /* [1] */
  268.         OK, visible, silent,
  269.         /* [2] */
  270.         OK, visible, silent,
  271.         /* [3] */
  272.         OK, visible, silent,
  273.         /* [4] */
  274.         OK, visible, silent
  275.     }
  276. };
  277.  
  278.  
  279. resource 'DITL' (rUserAlert, purgeable) {
  280.     { /* array DITLarray: 3 elements */
  281.         /* [1] */
  282.         {80, 150, 100, 230},
  283.         Button {
  284.             enabled,
  285.             "OK"
  286.         },
  287.         /* [2] */
  288.         {10, 60, 60, 230},
  289.         StaticText {
  290.             disabled,
  291.             "Error. ^0."
  292.         },
  293.         /* [3] */
  294.         {8, 8, 40, 40},
  295.         Icon {
  296.             disabled,
  297.             2
  298.         }
  299.     }
  300. };
  301.  
  302.  
  303. resource 'WIND' (rDocWindow, preload, purgeable) {
  304.     {64, 60, 314, 460},
  305.     zoomDocProc, invisible, goAway, 0x0, "untitled"
  306. };
  307.  
  308.  
  309. resource 'CNTL' (rVScroll, preload, purgeable) {
  310.     {-1, 385, 236, 401},
  311.     0, visible, 0, 0, scrollBarProc, 0, ""
  312. };
  313.  
  314.  
  315. resource 'CNTL' (rHScroll, preload, purgeable) {
  316.     {235, -1, 251, 386},
  317.     0, visible, 0, 0, scrollBarProc, 0, ""
  318. };
  319.  
  320. resource 'STR#' (kErrStrings, purgeable) {
  321.     {
  322.     "You must run on 512Ke or later";
  323.     "Application Memory Size is too small";
  324.     "Not enough memory to run TESample";
  325.     "Not enough memory to do Cut";
  326.     "Cannot do Cut";
  327.     "Cannot do Copy";
  328.     "Cannot exceed 32,000 characters with Paste";
  329.     "Not enough memory to do Paste";
  330.     "Cannot create window";
  331.     "Cannot exceed 32,000 characters";
  332.     "Cannot do Paste"
  333.     }
  334. };
  335.  
  336. /* here is the quintessential MultiFinder friendliness device, the SIZE resource */
  337.  
  338. resource 'SIZE' (-1) {
  339.     dontSaveScreen,
  340.     acceptSuspendResumeEvents,
  341.     enableOptionSwitch,
  342.     canBackground,                /* we can background; we don't currently, but our sleep value */
  343.                                 /* guarantees we don't hog the Mac while we are in the background */
  344.     multiFinderAware,            /* this says we do our own activate/deactivate; don't fake us out */
  345.     backgroundAndForeground,    /* this is definitely not a background-only application! */
  346.     dontGetFrontClicks,            /* change this is if you want "do first click" behavior like the Finder */
  347.     kPrefSize * 1024,
  348.     kMinSize * 1024
  349. };
  350.  
  351.  
  352. type 'MOOT' as 'STR ';
  353.  
  354.  
  355. resource 'MOOT' (0) {
  356.     "MultiFinder-Aware TextEdit Sample Application"
  357. };
  358.  
  359.  
  360. resource 'BNDL' (128) {
  361.     'MOOT',
  362.     0,
  363.     {
  364.         'ICN#',
  365.         {
  366.             0, 128
  367.         },
  368.         'FREF',
  369.         {
  370.             0, 128
  371.         }
  372.     }
  373. };
  374.  
  375.  
  376. resource 'FREF' (128) {
  377.     'APPL',
  378.     0,
  379.     ""
  380. };
  381.  
  382.  
  383. resource 'ICN#' (128) {
  384.     { /* array: 2 elements */
  385.         /* [1] */
  386.         $"04 30 40 00 0A 50 A0 00 0B 91 10 02 08 22 08 03"
  387.         $"12 24 04 05 20 28 02 09 40 10 01 11 80 0C 00 A1"
  388.         $"80 03 FF C2 7E 00 FF 04 01 00 7F 04 03 00 1E 08"
  389.         $"04 E0 00 0C 08 E0 00 0A 10 E0 00 09 08 C0 00 06"
  390.         $"04 87 FE 04 02 88 01 04 01 88 00 84 00 88 00 44"
  391.         $"00 88 00 44 00 88 00 C4 01 10 01 88 02 28 03 10"
  392.         $"01 C4 04 E0 00 02 08 00 73 BF FB EE 4C A2 8A 2A"
  393.         $"40 AA AA EA 52 AA AA 24 5E A2 8A EA 73 BE FB 8E",
  394.         /* [2] */
  395.         $"04 30 40 00 0E 70 E0 00 0F F1 F0 02 0F E3 F8 03"
  396.         $"1F E7 FC 07 3F EF FE 0F 7F FF FF 1F FF FF FF BF"
  397.         $"FF FF FF FE 7F FF FF FC 01 FF FF FC 03 FF FF F8"
  398.         $"07 FF FF FC 0F FF FF FE 1F FF FF FF 0F FF FF FE"
  399.         $"07 FF FF FC 03 FF FF FC 01 FF FF FC 00 FF FF FC"
  400.         $"00 FF FF FC 00 FF FF FC 01 FF FF F8 03 EF FF F0"
  401.         $"01 C7 FC E0 00 03 F8 00 73 BF FB EE 7F BE FB EE"
  402.         $"7F BE FB EE 7F BE FB E4 7F BE FB EE 73 BE FB 8E"
  403.     }
  404. };
  405.  
  406.